<?php
	require_once('../../config/koneksi.php');
	require_once('../../config/class_paging_param.php');
	require_once('../../config/fungsi_tgl_indo.php');
	require_once('../../config/library.php');	
?>
<link href="../../asset/css/admin_style.css" type="text/css" rel="stylesheet">
<link href="../../asset/css/paging.css" rel="stylesheet" type="text/css">
<title>Simjamkesda Berau</title>
<div id="satu">
	<div id="satu_con2">
		<div id="satu_a"><img src="../../asset/images/berau.png" height="65" style="padding-top: 5px;"/></div>
		<div id="satu_b">
			
		</div>
	</div>
</div>
<div id="dua"></div>
<div id="tiga">
	<?php
		$rs = $_GET['ppk'];
		$jns = $_GET['jns'];
		if($rs != ''){
			$id_rs = "and kl.id_ppk = '$rs'";
		}else{
			$id_rs = "";
		}
		
		if($_SESSION['id_jenis_pengguna'] == 5){
			$user = "and kl.id_verifikator = $_SESSION[id_pengguna]";
		}else{
			$user = "";
		}
		
		$p = new paging ;
		$batas = 20;
			
		if($jns == 'inacbg'){
			$id = $_GET['id'];
	
			//cek halaman dan posisi halaman
			$posisi = $p ->cariposisi($batas) ;
			$sql = "select kl.id_klaim,kl.tgl_trans,pn.nama,jk,  kl.no_rm,(YEAR(kl.tgl_trans)-YEAR(pn.tgl_lahir)) AS umur, DATEDIFF(kl.tgl_keluar,kl.tgl_masuk) as los, kl.total_diminta from klaim kl inner join peserta p on p.id_peserta = kl.id_peserta inner join penduduk pn on pn.id_penduduk = p.id_penduduk where kl.id_status = $id and jenis_klaim = 'inacbg' $id_rs $user and (id_jenis_layanan = 1 or id_jenis_layanan = 3) limit $posisi,$batas";
			$qry=mysql_query($sql);
			if(mysql_num_rows($qry)>0){
		?>
		<table class="tabel3">
			<tr>
				<th>NO</th>
				<th>Tanggal</th>
				<th>Nama</th>
				<th>No MR</th>
				<th>Umur</th>
				<th>JK</th>
				<th>No SJP</th>
				<th>LOS</th>
				<th>Nama Dokter</th>
				<th>Diagnosa</th>
				<th>Prosedur</th>
				<th>Kode INA-CBG</th>
				<th>Obat</th>
				<th>Total Klaim</th>
			</tr>
			
			<?php
				//echo "cc$sql";
				$no=$posisi + 1;
					while($hasil=mysql_fetch_array($qry)){					
			?>	
						<tr>
							<td align="center" width="30"><?php echo $no;?></td>
							<td align="center" >
								<?php echo tgl_ind1($hasil['tgl_trans']);?>
							</td>
							<td>
								<?php echo $hasil['nama'];?>
							</td>
							<td align="center"><?php echo $hasil['no_rm'];?></td>
							<td align="center"><?php echo $hasil['umur'];?></td>
							<td align="center"><?php echo $hasil['jk'];?></td>
							<td ></td>
							<td align="center"><?php echo $hasil['los'];?></td>
							<td></td>
							<td>
								<?php
									$diagnosis = mysql_query("select m.icd10,m.keterangan from klaim_diagnosis kd inner join master_diagnosis m on kd.icd10 = m.icd10 where kd.id_klaim = '$hasil[id_klaim]'");
									while($d = mysql_fetch_array($diagnosis)){
										echo "<a title='$d[keterangan]'>$d[icd10]</a><br>";
									}
								?>
							</td>
							<td>
								<?php
									$prosedur = mysql_query("select m.icd9,m.keterangan from klaim_prosedur kd inner join master_prosedur m on kd.icd9 = m.icd9 where kd.id_klaim = '$hasil[id_klaim]'");
									while($d = mysql_fetch_array($diagnosis)){
										echo "<a title='$d[keterangan]'>$d[icd9]</a><br>";
									}
								?>
							</td>
							<td>
								<?php
									$inacbg = mysql_query("select m.kode_inacbg,m.deskripsi from klaim_inacbg ki inner join master_inacbg m on ki.kode_inacbg = m.kode_inacbg where ki.id_klaim = '$hasil[id_klaim]'");
									while($i = mysql_fetch_array($inacbg)){
										echo "<a title='$i[deskripsi]'>$i[kode_inacbg]</a><br>";
									}
								?>
							</td>
							<td>
								<?php
									$obat = mysql_query("select m.kode_obat,m.nama_obat from klaim_obat ko inner join master_obat m on ko.kode_obat = m.kode_obat where ko.id_klaim = '$hasil[id_klaim]'");
									while($o = mysql_fetch_array($inacbg)){
										echo "<a title='$o[nama_obat]'>$o[kode_obat]</a><br>";
									}
								?>
							</td>
							<td align="right">
								<?php echo desimal($hasil['total_diminta']);?>
							</td>
						</tr>
						
				<?php
						$no++;
					}
				?>
				</table>
				<br>
				<br>
			<?php
			}
		}else{
		?>
		
	<?php
		$id = $_GET['id'];

		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		$sql = "select kl.id_klaim,kl.tgl_trans,pn.nama,jk, kl.no_rm,(YEAR(kl.tgl_trans)-YEAR(pn.tgl_lahir)) AS umur, DATEDIFF(kl.tgl_keluar,kl.tgl_masuk) as los, kl.total_diminta from klaim kl inner join peserta p on p.id_peserta = kl.id_peserta inner join penduduk pn on pn.id_penduduk = p.id_penduduk where kl.id_status = $id and jenis_klaim = 'service' $id_rs and (id_jenis_layanan = 1 or id_jenis_layanan = 3) limit $posisi,$batas";
		//echo $sql;
	?>
	<table class="tabel3">
		<tr>
			<th>NO</th>
			<th>Tanggal</th>
			<th>Nama</th>
			<th>No MR</th>
			<th>Umur</th>
			<th>JK</th>
			<th>No SJP</th>
			<th>LOS</th>
			<th>Nama Dokter</th>
			<th>Diagnosa</th>
			<th>Tindakan</th>
			<th>Obat</th>
			<th>Total Klaim</th>
		</tr>
		
		<?php
			//echo "cc$sql";
			$qry=mysql_query($sql);
			$no=$posisi + 1;
			if(mysql_num_rows($qry)>0){
				while($hasil=mysql_fetch_array($qry)){					
		?>	
					<tr>
						<td align="center" width="30"><?php echo $no;?></td>
						<td align="center" >
							<?php echo tgl_ind1($hasil['tgl_trans']);?>
						</td>
						<td>
							<?php echo $hasil['nama'];?>
						</td>
						<td align="center"><?php echo $hasil['no_rm'];?></td>
						<td align="center"><?php echo $hasil['umur'];?></td>
						<td align="center"><?php echo $hasil['jk'];?></td>
						<td ></td>
						<td align="center"><?php echo $hasil['los'];?></td>
						<td></td>
						<td>
							<?php
								$diagnosis = mysql_query("select m.icd10,m.keterangan from klaim_diagnosis kd inner join master_diagnosis m on kd.icd10 = m.icd10 where kd.id_klaim = '$hasil[id_klaim]'");
								while($d = mysql_fetch_array($diagnosis)){
									echo "<a title='$d[keterangan]'>$d[icd10]</a><br>";
								}
							?>
						</td>
						<td>
							<?php
								$tindakan = mysql_query("select m.id_tindakan,m.nama_tindakan from klaim_tindakan kt inner join master_tindakan m on kt.id_tindakan = m.id_tindakan where kt.id_klaim = '$hasil[id_klaim]'");
								while($t = mysql_fetch_array($tindakan)){
									//echo "<a title='$t[nama_tindakan]'>$t[id_tindakan]</a><br>";
									echo "$t[nama_tindakan] <br>";
								}
							?>
						</td>
						<td>
							<?php
								$obat = mysql_query("select m.kode_obat,m.nama_obat from klaim_obat ko inner join master_obat m on ko.id_obat = m.kode_obat where ko.id_klaim = '$hasil[id_klaim]'");
								while($o = mysql_fetch_array($obat)){
									echo "<a title='$o[nama_obat]'>$o[kode_obat]</a><br>";
								}
							?>
						</td>
						<td align="right">
							<?php echo desimal($hasil['total_diminta']);?>
						</td>
					</tr>
					
			<?php
					$no++;
				}
			}else{
			?>
		
		<tr>
			<td colspan="13" align="center">Data tidak Ada </td>
		</tr>
		
		<?php
			}
		}
		?>
	</table>
	<?php
		if($jns == 'inacbg'){
			$sql2 = "select kl.id_klaim,kl.tgl_trans,pn.nama,jk,  kl.no_rm,(YEAR(kl.tgl_trans)-YEAR(pn.tgl_lahir)) AS umur, DATEDIFF(kl.tgl_keluar,kl.tgl_masuk) as los from klaim kl inner join peserta p on p.id_peserta = kl.id_peserta inner join penduduk pn on pn.id_penduduk = p.id_penduduk where kl.id_status = $id and jenis_klaim = 'inacbg' $id_rs";
		}else{
			$sql2 = "select kl.id_klaim,kl.tgl_trans,pn.nama,jk,  kl.no_rm,(YEAR(kl.tgl_trans)-YEAR(pn.tgl_lahir)) AS umur, DATEDIFF(kl.tgl_keluar,kl.tgl_masuk) as los from klaim kl inner join peserta p on p.id_peserta = kl.id_peserta inner join penduduk pn on pn.id_penduduk = p.id_penduduk where kl.id_status = $id and jenis_klaim = 'service' $id_rs";
		}
		
		$query2=mysql_query($sql2);
		$jumlah_data=mysql_num_rows($query2);
		//dapatkan jumlah halaman
		$jumlah_halaman= $p->jumlahhalaman($jumlah_data,$batas);
		//cetak link
		$linkhalaman=$p->navhalaman($_GET['halaman'],$jumlah_halaman,$_SERVER['PHP_SELF']."?id=$id&jns=$jns&ppk=$rs");
		print($linkhalaman);
	?>
</div>
<div id="empat">
	<div id="empat_con2">
		<div id="empat_a">Copyright &copy 2013 Dinas Kesehatan Kabupaten Berau</div>
		<div id="empat_b">Developed By <a href="#" target="_Blank">Dept. IT Kabupaten Berau</a></div>
	</div>
</div>
        